package com.protocolterminal.AFN;

import java.util.Arrays;
import java.util.List;

import com.protocolterminal.AFN.entity.*;

public class AFN04 extends BaseAFN {

	public AFN04(String AFN, String SEQ, List<String> DA, List<String> DT, List<String> Data, String AUX) {
		this.AFN = AFN;
		this.SEQ = SEQ;
		this.DA = DA;
		this.DT = DT;
		this.Data = Data;
		this.AUX = AUX;

	}

	@Override
	public String toString() {
		String data = "";
		try {
			for (int i = 0; i < DA.size(); i++) {
				String datatemp = "";
				Interface_Data interface_Data = null;
				switch (DT.get(i)) {
				case "0100":// F1终端上行通信参数设置
					interface_Data = new AFN04F1();
					break;
				case "0400":// F3终端IP地址和端口
					interface_Data = new AFN04F3();
					break;
				case "0201":// F10终端电能表、交流采用设置
					interface_Data = new AFN04F10();
					break;
				default:
					break;
				}
				datatemp = interface_Data.listtoframe(Arrays.asList(Data.get(i).split("-")));

				data += this.DA.get(i) + this.DT.get(i) + datatemp;
			}
		} catch (Exception e) {
			System.err.println(e.getMessage());
		}

		return this.AFN + this.SEQ + data + this.AUX;
	}

}
